package networks.manager;

public class Consts {

    public enum RETURN_CODE {
        SUCCESS(200), //
        ERROR(0);//

        private final int _value;

        private RETURN_CODE(int value) {
            _value = value;
        }

        public int ToInt() {
            return _value;
        }

        public static RETURN_CODE ToEnum(int value) {
            for (RETURN_CODE e : RETURN_CODE.values()) {
                if (e.ToInt() == value)
                    return e;
            }
            return RETURN_CODE.ERROR;
        }
    }

    public enum LOGIN_CODE {
        SUCCESS(200), //
        FAIL_NOT_EXIST(500), // User does not exist
        FAIL_WRONG(501), // Wrong account or password
        FAIL_DUPLICATE(502);// Duplicate login

        private final int _value;

        private LOGIN_CODE(int value) {
            _value = value;
        }

        public int ToInt() {
            return _value;
        }

        public static LOGIN_CODE ToEnum(int value) {
            for (LOGIN_CODE e : LOGIN_CODE.values()) {
                if (e.ToInt() == value)
                    return e;
            }
            return LOGIN_CODE.FAIL_NOT_EXIST;
        }
    }
}
